/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Menus;

import Control.ButtonController;
import Control.GameController;
import Highscore.Highscore;
import Highscore.Score;
import UserInterface.Button;
import gleem.linalg.Vec4f;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;

/**
 * Menu de game over
 * @author Gustavo Buzogany Eboli
 */
public class GameOver extends Menu {

    Highscore hs;
    TreeMap scores;

    public GameOver(GameController gc)
    {
        super(gc);

        int i = 0;
        int tam = 0;
        Score aux;
        Integer auxkey;

        hs = gc.getHs();

        Button newGame = new Button("newGame",70, 350, 200, 30, "New Game");
        newGame.setColor(new Vec4f(0.25f, 0.25f, 1.0f, 1.0f));

        Button loadGame = new Button("loadGame", 70, 400, 200, 30, "Load Game");
        loadGame.setColor(new Vec4f(0.25f, 0.25f, 1.0f, 1.0f));

        Button exit = new Button("exit", 70, 450, 200, 30, "Exit");
        exit.setColor(new Vec4f(0.25f, 0.25f, 1.0f, 1.0f));

        buttonList.add(newGame);
        buttonList.add(loadGame);
        buttonList.add(exit);

        scores = hs.getListaScore();

        tam = scores.size();

        Set keys = scores.keySet();
        Iterator it = keys.iterator();

        while(it.hasNext() && i < 15)
        {
            auxkey = (Integer) it.next();
            aux = (Score) scores.get(auxkey);
            i++;
            Button scoreid = new Button("score", 360, 200+30*tam-30*(i-1), 40, 25, ""+(tam-i+1)+"");
            scoreid.setColor(new Vec4f(0.3f, 0.3f, 1.0f, 1.0f));
            scoreid.setSound(false);

            Button scoreexp = new Button("score", 405, 200+30*tam-30*(i-1), 100, 25, ""+aux.getExp());
            scoreexp.setSound(false);

            Button scorename = new Button("score", 510, 200+30*tam-30*(i-1), 150, 25, aux.getName());
            scorename.setSound(false);

            buttonList.add(scoreid);
            buttonList.add(scoreexp);
            buttonList.add(scorename);
        }


        ButtonController bc = new ButtonController(gc);

        newGame.addButtonListener(bc);
        loadGame.addButtonListener(bc);
        exit.addButtonListener(bc);
    }
}
